﻿using YunShop_WebAPI.BLL;
using YunShop_WebAPI.Model;
using System.Collections;
using System.Web;
using System.Web.Http;
using System;
using System.IO;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Web.Hosting;
using System.Configuration;
using System.Globalization;
using Newtonsoft.Json;

namespace YunShop_WebAPI.API.Controllers
{
    /// <summary>
    /// 商户管理小程序(商云管家)
    /// </summary>
    public class MiniManageController : ApiController
    {
        /// <summary>
        /// 1.11、商家登录
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("OnUserLogin")]
        public Result_Model OnUserLogin()
        {
            string usercode = CommonFun.ConvertToString(HttpContext.Current.Request["usercode"]);
            string password = CommonFun.ConvertToString(HttpContext.Current.Request["password"]);
            string appid = CommonFun.ConvertToString(HttpContext.Current.Request["appid"]);
            string code = CommonFun.ConvertToString(HttpContext.Current.Request["code"]);
            int status = 0;
            string message = "获取成功";
            ArrayList data = MiniMngCommon.OnUserLogin(appid, code, usercode, password, ref status, ref message);
            return new Result_Model(status, message, data);
        }

        /// <summary>
        /// 1.12、会员列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetMemberList")]
        public Result_Model GetMemberList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetMemberList(shop_appid, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.13、商品列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetGoodsList")]
        public Result_Model GetGoodsList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetGoodsList(shop_appid, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.14、商品库存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetStockTotal")]
        public Result_Model GetStockTotal()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetStockTotal(shop_appid, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.15、会员信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetMemberInfo")]
        public Result_Model GetMemberInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 item_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            Hashtable data = MiniMngCommon.GetMemberInfo(shop_appid, item_id);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.16、商品信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetGoodsInfo")]
        public Result_Model GetGoodsInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 item_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            Hashtable data = MiniMngCommon.GetGoodsInfo(shop_appid, item_id);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.17、商品保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetGoodsInfo")]
        public Result_Model SetGoodsInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            GoodsModel goodsModel = new GoodsModel();
            goodsModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            goodsModel.FNumber = CommonFun.ConvertToString(HttpContext.Current.Request["FNumber"]);
            goodsModel.FCode = CommonFun.ConvertToString(HttpContext.Current.Request["FCode"]);
            goodsModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            goodsModel.FSpec = CommonFun.ConvertToString(HttpContext.Current.Request["FSpec"]);
            goodsModel.FUnitName = CommonFun.ConvertToString(HttpContext.Current.Request["FUnitName"]);
            goodsModel.FClassID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FClassID"]);
            goodsModel.FPurPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FPurPrice"]);
            goodsModel.FPosPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FPosPrice"]);
            goodsModel.FSelPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FSelPrice"]);
            goodsModel.FVipPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FVipPrice"]);
            goodsModel.FMallPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FMallPrice"]);
            goodsModel.FRmoPrice = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FRmoPrice"]);
            goodsModel.FPoint = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FPoint"]);
            goodsModel.FPriceType = CommonFun.ConvertToInt(HttpContext.Current.Request["FPriceType"]);
            goodsModel.FSupplyItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FSupplierID"]);
            goodsModel.FHome = CommonFun.ConvertToString(HttpContext.Current.Request["FHome"]);
            goodsModel.FLife = CommonFun.ConvertToInt(HttpContext.Current.Request["FLife"]);
            goodsModel.FDeleted = CommonFun.ConvertToInt(HttpContext.Current.Request["FDeleted"]);
            goodsModel.FWeighPlu = CommonFun.ConvertToInt(HttpContext.Current.Request["FWeighPlu"]);

            string sGoodsImgList = CommonFun.ConvertToString(HttpContext.Current.Request["FGoodsImgList"]);

            MiniMngCommon.SetGoodsImg(shop_appid, sGoodsImgList, ref goodsModel);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetGoodsInfo(goodsModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.18、会员保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetMemberInfo")]
        public Result_Model SetMemberInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            MemberModel memberModel = new MemberModel();
            memberModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            memberModel.FNumber = CommonFun.ConvertToString(HttpContext.Current.Request["FNumber"]);
            memberModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            memberModel.FMembersClassID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FClassID"]);
            memberModel.FMemberRankID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FMemberRankID"]);
            memberModel.FDiscount = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FDiscount"]);
            memberModel.FPhone = CommonFun.ConvertToString(HttpContext.Current.Request["FPhone"]);
            memberModel.FAddress = CommonFun.ConvertToString(HttpContext.Current.Request["FAddress"]);
            memberModel.FEmail = CommonFun.ConvertToString(HttpContext.Current.Request["FEmail"]);
            memberModel.FBirthday = CommonFun.ConvertToDateTime(HttpContext.Current.Request["FBirthday"]).ToString("yyyy-MM-dd");
            memberModel.FRemark = CommonFun.ConvertToString(HttpContext.Current.Request["FRemark"]);
            memberModel.FSheAmount = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FSheAmount"]);
            memberModel.FSheFlag = CommonFun.ConvertToString(HttpContext.Current.Request["FSheFlag"]);
            memberModel.FSex = CommonFun.ConvertToInt(HttpContext.Current.Request["FSex"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetMemberInfo(memberModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.19、信息选择
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SelectItems")]
        public Result_Model SelectItems()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string type = CommonFun.ConvertToString(HttpContext.Current.Request["type"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int mclassid = CommonFun.ConvertToInt(HttpContext.Current.Request["parent_id"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.SelectItems(shop_appid, type, mclassid, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.20、会员分类保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetMemberType")]
        public Result_Model SetMemberType()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            MemberTypeModel mtypeModel = new MemberTypeModel();
            mtypeModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            mtypeModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            mtypeModel.FDiscount = CommonFun.ConvertToDecimal(HttpContext.Current.Request["FDiscount"]);
            mtypeModel.FTypeID = CommonFun.ConvertToInt(HttpContext.Current.Request["FTypeID"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetMemberType(mtypeModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.21、商品分类保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetGoodsType")]
        public Result_Model SetGoodsType()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            GoodsTypeModel gtypeModel = new GoodsTypeModel();
            gtypeModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            gtypeModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            gtypeModel.FFreshType = CommonFun.ConvertToInt(HttpContext.Current.Request["FTypeID"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetGoodsType(gtypeModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.22、供应商信息保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetSupplier")]
        public Result_Model SetSupplier()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            SupplierModel supplierModel = new SupplierModel();
            supplierModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            supplierModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            supplierModel.FPhone = CommonFun.ConvertToString(HttpContext.Current.Request["FPhone"]);
            supplierModel.FContacts = CommonFun.ConvertToString(HttpContext.Current.Request["FContacts"]);
            supplierModel.FAddress = CommonFun.ConvertToString(HttpContext.Current.Request["FAddress"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetSupplier(supplierModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.23、供应商信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetSupplierInfo")]
        public Result_Model GetSupplierInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 item_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            Hashtable data = MiniMngCommon.GetInfo(shop_appid, item_id, "t_Supplier");
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.24、供应商列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetSupplierList")]
        public Result_Model GetSupplierList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetSupplierList(shop_appid, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.25、单据商品选择
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetBillGoods")]
        public Result_Model GetBillGoods()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            Int64 item_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetBillGoods(shop_appid, name, item_id, type, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.26、增加采购入库
        /// </summary>
        [HttpPost]
        [ActionName("AddWarehous")]
        public Result_Model AddWarehous()
        {
            try
            {
                string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
                Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
                StreamReader rd = new StreamReader(xmlStream);
                string json = rd.ReadToEnd();
                Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
                int sSupplierID = CommonFun.ConvertToInt(row["FSupplierID"]);
                int mDataType = CommonFun.ConvertToInt(row["FDataType"]);
                Int64 mKinterID = CommonFun.ConvertToInt(row["KInterID"]);
                string remark = CommonFun.ConvertToString(row["FRemark"]);
                ArrayList detailed = row["detail"] as ArrayList;
                int mResult = 0;
                string msg = "保存失败";

                Hashtable data = MiniMngCommon.AddWarehous(shop_appid, mKinterID, sSupplierID,
                    remark, mDataType, detailed, ref mResult, ref msg);
                return new Result_Model(mResult, msg, data);
            }
            catch (Exception ex)
            {
                return new Result_Model(0, ex.Message, null);
            }
        }

        /// <summary>
        /// 1.27、采购入库列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetWarehousList")]
        public Result_Model GetWarehousList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            int checkflag = CommonFun.ConvertToInt(HttpContext.Current.Request["checkflag"]);
            int datatype = CommonFun.ConvertToInt(HttpContext.Current.Request["data_type"]);
            ArrayList data = MiniMngCommon.GetWarehousList(shop_appid, name, page_index, page_size,
                star_date, end_date, datatype, checkflag, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.28、信息列表
        /// </summary>
        [HttpGet]
        [ActionName("GetBaseItemList")]
        public Result_Model GetBaseItemList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string type = CommonFun.ConvertToString(HttpContext.Current.Request["type"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetBaseItemList(shop_appid, type, name, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.29、单据审核
        /// </summary>
        [HttpPost]
        [ActionName("SetBillAudit")]
        public Result_Model SetBillAudit()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 bill_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["bill_id"]);
            int bill_type = CommonFun.ConvertToInt(HttpContext.Current.Request["bill_type"]);
            int mResult = 0;
            string msg = "审核失败";
            Hashtable data = MiniMngCommon.SetBillAudit(shop_appid, bill_id, bill_type, ref mResult, ref msg);
            return new Result_Model(mResult, msg, data);
        }

        /// <summary>
        /// 1.30、会员等级保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetMemberRank")]
        public Result_Model SetMemberRank()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            BaseInfoModel baseInfoModel = new BaseInfoModel();
            baseInfoModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            baseInfoModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetMemberRank(baseInfoModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.31、删除资料信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("DeleteInfo")]
        public Result_Model DeleteInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            int mResult = 0;
            string msg = "删除失败";
            Hashtable ht_reust = MiniMngCommon.DeleteInfo(shop_appid, FItemID, type, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.34、商品排行
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptGoodsSort")]
        public Result_Model RptGoodsSort()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            ArrayList data = MiniMngCommon.RptGoodsSort(shop_appid, shop_id, name, page_index, page_size,
                star_date, end_date, type, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.35、收银汇总
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptCashSummary")]
        public Result_Model RptCashSummary()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            string bill_no = CommonFun.ConvertToString(HttpContext.Current.Request["bill_no"]);
            ArrayList data = MiniMngCommon.RptCashSummary(shop_appid, shop_id, bill_no, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.36、会员充值消费明细
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptRechargeRecord")]
        public Result_Model RptRechargeRecord()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            string phone = CommonFun.ConvertToString(HttpContext.Current.Request["phone"]);
            ArrayList data = MiniMngCommon.RptRechargeRecord(shop_appid, shop_id, type, phone, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        ///  1.37、单个文件上传到微信服务器（图片，视频，以及其他文件）
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("UploadFile")]
        public Result_Model UploadFile()
        {
            try
            {
                string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
                HttpPostedFile file = System.Web.HttpContext.Current.Request.Files["file"];
                if (file.ContentLength == 0) return new Result_Model(2, "请上传文件");

                string mSubPath = "/Upload/proImage/";
                string FileExtension = Path.GetExtension(file.FileName).ToLower();
                if (FileExtension == ".jpg" || FileExtension == ".jpeg" || FileExtension == ".png" || FileExtension == ".mp4" || FileExtension == ".gif" || FileExtension == ".mp3")
                {
                    string sFileName = "goodsimg_tmp" + FileExtension;
                    string SavePath = mSubPath + sFileName;
                    //Directory.CreateDirectory(HostingEnvironment.MapPath("/upload/weixin/"));
                    file.SaveAs(HostingEnvironment.MapPath(SavePath));
                    int mResult = 0;
                    string msg = "上传失败";
                    string SavePathAll = HttpContext.Current.Server.MapPath(mSubPath) + sFileName;
                    Hashtable ht = MiniMngCommon.UploadImage(shop_appid, SavePathAll, "upload", ref mResult, ref msg);
                    return new Result_Model(mResult, "文件上传成功", ht);
                }
                else
                {
                    return new Result_Model(2, "请重新选择上传文件");
                }
            }
            catch (Exception ex)
            {
                return new Result_Model(2, "出错了", ex.ToString());
            }
        }

        /// <summary>
        ///  1.37、文件上传到微信服务器（图片，视频，以及其他文件）--未启用
        ///  E:\18_YunShop\KLWL_CHAIN\KLWL_CHAIN.Web\webapi\OSSUploadFileMany
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionName("UploadFiles")]
        public Result_Model UploadFiles()
        {
            try
            {
                string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
                string catalog = HttpContext.Current.Request["catalog"];
                string account = HttpContext.Current.Request["account"];
                HttpFileCollection files = HttpContext.Current.Request.Files;
                if (!(files != null && files.Count > 0)) return new Result_Model(2, "请上传文件");
                List<string> list = new List<string>();
                for (int i = 0; i < files.Count; i++)
                {
                    HttpPostedFile file_info = files[i];
                    if (file_info.ContentLength <= 0)
                    {
                        list.Add("");
                        continue;
                    }
                    string file_name = BLL.Utils.GetGuidIntID().ToString().Substring(0, 14);
                    string oss_name = catalog + "/" + file_name + "." + BLL.Utils.GetFileExt(file_info.FileName);
                    //string url = BLL.Common.OSS_UploadFile(oss_name, file_info.InputStream, out string file_size, out string error);
                    //添加记录
                    //if (string.IsNullOrEmpty(error))
                    {
                        //BLL.Common.AddNewPictureStorage(dbconn_manage, account, business_id, files.AllKeys[i], oss_name, string.Empty, file_size);                        
                    }
                    //list.Add(!string.IsNullOrEmpty(url) ? url : error);
                }
                return new Result_Model(1, "上传成功", list, list.Count);
            }
            catch (Exception ex)
            {
                return new Result_Model(2, "出错了", ex.ToString());
            }
        }

        /// <summary>
        /// 1.38、单据详情
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetBillData")]
        public Result_Model GetBillData()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int bill_type = CommonFun.ConvertToInt(HttpContext.Current.Request["bill_type"]);
            Int64 bill_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["bill_id"]);
            Hashtable data = MiniMngCommon.GetBillData(shop_appid, bill_type, bill_id);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.39、门店综合报表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptStockAnalysis")]
        public Result_Model RptStockAnalysis()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            ArrayList data = MiniMngCommon.RptStockAnalysis(shop_appid, shop_id, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.40、门店营业概况
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptBusinessDaily")]
        public Result_Model RptBusinessDaily()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            //24小时验证Token
            int mDay = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.LoginDate);
            if (mDay != DateTime.Now.Day)
            {
                if (!MiniMngCommon.OnUserExists(shop_appid))
                    return new Result_Model(401, "登录已失效", null);
            }
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            Hashtable data = MiniMngCommon.RptBusinessDaily(shop_appid, shop_id);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.41、采购入库列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetMallOrderList")]
        public Result_Model GetMallOrderList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            int bill_type = CommonFun.ConvertToInt(HttpContext.Current.Request["bill_type"]);
            int bill_state = CommonFun.ConvertToInt(HttpContext.Current.Request["bill_state"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            ArrayList data = MiniMngCommon.GetMallOrderList(shop_appid, shop_id, name, page_index, page_size,
                star_date, end_date, bill_type, bill_state, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.42、通用信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetBaseItemInfo")]
        public Result_Model GetBaseItemInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 item_id = CommonFun.ConvertToBigInt(HttpContext.Current.Request["item_id"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            Hashtable data = MiniMngCommon.GetBaseItemInfo(shop_appid, item_id, type);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.43、交易分析
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptBuyingAnalysis")]
        public Result_Model RptBuyingAnalysis()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            Hashtable data = MiniMngCommon.RptBuyingAnalysis(shop_appid, shop_id, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.44、客流量分析
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptBuyingFlow")]
        public Result_Model RptBuyingFlow()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            ArrayList data = MiniMngCommon.RptBuyingFlow(shop_appid, shop_id, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.45、客流时段分析
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptAnalysisTime")]
        public Result_Model RptAnalysisTime()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            ArrayList data = MiniMngCommon.RptAnalysisTime(shop_appid, shop_id, star_date, end_date);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.46、销售分析
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptMarketAnalysis")]
        public Result_Model RptMarketAnalysis()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            Hashtable data = MiniMngCommon.RptMarketAnalysis(shop_appid, shop_id, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.47、导购员绩效
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptDawEmploy")]
        public Result_Model RptDawEmploy()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            Hashtable data = MiniMngCommon.RptDawEmploy(shop_appid, shop_id, type, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.48、库存盘点
        /// </summary>
        [HttpPost]
        [ActionName("AddInventory")]
        public Result_Model AddInventory()
        {
            try
            {
                string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
                Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
                StreamReader rd = new StreamReader(xmlStream);
                string json = rd.ReadToEnd();
                Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
                Int64 mKinterID = CommonFun.ConvertToInt(row["KInterID"]);
                string remark = CommonFun.ConvertToString(row["FRemark"]);
                ArrayList detailed = row["detail"] as ArrayList;
                int mResult = 0;
                string msg = "保存失败";

                Hashtable data = MiniMngCommon.AddInventory(shop_appid, mKinterID, remark, detailed, ref mResult, ref msg);
                return new Result_Model(mResult, msg, data);
            }
            catch (Exception ex)
            {
                return new Result_Model(0, ex.Message, null);
            }
        }

        /// <summary>
        /// 1.49、库存盘点列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetInventoryList")]
        public Result_Model GetInventoryList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            int checkflag = CommonFun.ConvertToInt(HttpContext.Current.Request["checkflag"]);
            ArrayList data = MiniMngCommon.GetInventoryList(shop_appid, name, page_index, page_size,
                star_date, end_date, checkflag, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.50、完成盘点
        /// </summary>
        [HttpPost]
        [ActionName("SetInventoryAudit")]
        public Result_Model SetInventoryAudit()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int type = CommonFun.ConvertBooleanToInt(HttpContext.Current.Request["type"]);
            int mResult = 0;
            string msg = "完成盘点失败";
            Hashtable data = MiniMngCommon.SetInventoryAudit(shop_appid, type, ref mResult, ref msg);
            return new Result_Model(mResult, msg, data);
        }

        /// <summary>
        /// 1.51、门店资料
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetShopInfo")]
        public Result_Model GetShopInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Int64 item_id = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.CorpID);
            Hashtable data = MiniMngCommon.GetBaseItemInfo(shop_appid, item_id, 10);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.52、门店资料保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetShopInfo")]
        public Result_Model SetShopInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            string FManager = CommonFun.ConvertToString(HttpContext.Current.Request["FManager"]);
            string FAddress = CommonFun.ConvertToString(HttpContext.Current.Request["FAddress"]);
            int mResult = 0;
            string msg = "保存失败";

            Hashtable data = MiniMngCommon.SetShopInfo(shop_appid, FName, FManager, FAddress, ref mResult, ref msg);
            return new Result_Model(mResult, msg, data);
        }

        /// <summary>
        /// 1.53、系统信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetSystemInfo")]
        public Result_Model GetSystemInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            int mResult = 0;
            string msg = "保存失败";

            Hashtable data = MiniMngCommon.GetSystemInfo(shop_appid, type, ref mResult, ref msg);
            return new Result_Model(mResult, msg, data);
        }

        /// <summary>
        /// 1.54、用户信息保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetUserInfo")]
        public Result_Model SetUserInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
            StreamReader rd = new StreamReader(xmlStream);
            string json = rd.ReadToEnd();
            Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetUserInfo(row, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.55、导购员保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetEmployeeInfo")]
        public Result_Model SetEmployeeInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
            StreamReader rd = new StreamReader(xmlStream);
            string json = rd.ReadToEnd();
            Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetEmployeeInfo(row, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.56、会员等级保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetTimeType")]
        public Result_Model SetTimeType()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            BaseInfoModel baseInfoModel = new BaseInfoModel();
            baseInfoModel.FItemID = CommonFun.ConvertToBigInt(HttpContext.Current.Request["FItemID"]);
            baseInfoModel.FName = CommonFun.ConvertToString(HttpContext.Current.Request["FName"]);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetTimeType(baseInfoModel, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.58、次卡资料保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetTimeInfo")]
        public Result_Model SetTimeInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
            StreamReader rd = new StreamReader(xmlStream);
            string json = rd.ReadToEnd();
            Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetTimeInfo(row, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.59、获取商品条码库
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetSysGoodByCode")]
        public Result_Model GetSysGoodByCode()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string mCode = CommonFun.ConvertToString(HttpContext.Current.Request["code"]);
            int mResult = 0;
            string msg = "获取失败";
            Hashtable ht_reust = MiniMngCommon.GetSysGoodByCode(shop_appid, mCode, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.61、收银员权限保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetCashierAuthority")]
        public Result_Model SetCashierAuthority()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
            StreamReader rd = new StreamReader(xmlStream);
            string json = rd.ReadToEnd();
            Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
            int mResult = 0;
            string msg = "保存失败";
            Hashtable ht_reust = MiniMngCommon.SetCashierAuthority(row, shop_appid, ref mResult, ref msg);
            return new Result_Model(mResult, msg, ht_reust);
        }

        /// <summary>
        /// 1.62、商品库存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptTimeInventory")]
        public Result_Model RptTimeInventory()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int time_id = CommonFun.ConvertToInt(HttpContext.Current.Request["time_id"]);
            int member_id = CommonFun.ConvertToInt(HttpContext.Current.Request["member_id"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.RptTimeInventory(shop_appid, time_id, member_id, page_index, page_size, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.63、充值续费
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetRenewals")]
        public Result_Model GetRenewals()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            ArrayList data = MiniMngCommon.GetRenewals(shop_appid);
            return new Result_Model(1, "获取成功", data);
        }



         /// <summary>
         /// 1.64、获取微信支付信息
         /// </summary>
         [HttpPost]
         [ActionName("SetRenewalsPay")]
         public Result_Model SetRenewalsPay()
         {
             string msg = "";
             string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
             Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
             StreamReader rd = new StreamReader(xmlStream);
             string json = rd.ReadToEnd();
             Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
             string openid = CommonFun.ConvertToString(row["openid"]);
             decimal total_fee = CommonFun.ConvertToDecimal(row["total_fee"]);

             int years= CommonFun.ConvertToInt(row["years"]);
             if (years == 0) years = 1;
             ArrayList rows = row["detaileds"] as ArrayList;

             //total_fee = CommonFun.ConvertToDecimal(0.01);

             int shop_id = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.CorpID);
             int user_id = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.UserID);

             int type = 0;//0是充值续费，2是短信充值
             //生成支付订单
             string out_trade_no = MiniMngCommon.SaveRenewalsOrder(shop_id,user_id,total_fee, years, ref msg, type, shop_appid);
             if (out_trade_no == "") return new Result_Model(2, !string.IsNullOrEmpty(msg) ? msg : "生成订单失败");

             //开始调用支付
             Dictionary<string, object> result = new Dictionary<string, object>();
             bool ret = SxfPayCommon.GetCreateOrderPay(shop_id, openid, total_fee, out_trade_no, ref msg, out result);
             if (!ret) return new Result_Model(2, !string.IsNullOrEmpty(msg) ? msg : "获取失败");

             //查询支付结果
             MiniMngCommon.SetRepeatQueryPay(rows, out_trade_no, shop_id, years, type, shop_appid);
             return new Result_Model(1, "获取成功", result);
         }

        /// <summary>
        /// 1.65、门店列表
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetShopList")]
        public Result_Model GetShopList()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string name = CommonFun.ConvertToString(HttpContext.Current.Request["name"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            ArrayList data = MiniMngCommon.GetShopList(shop_appid, name, page_index, page_size);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.66、收款分析
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptPayAnalysis")]
        public Result_Model RptPayAnalysis()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            ArrayList data = MiniMngCommon.RptPayAnalysis(shop_appid, shop_id, star_date, end_date);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.67、短信充值信息
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("GetSmsData")]
        public Result_Model GetSmsData()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Hashtable data = MiniMngCommon.GetSmsData(shop_appid);
            return new Result_Model(1, "获取成功", data);
        }

        /// <summary>
        /// 1.68、短信充值支付
        /// </summary>
        [HttpPost]
        [ActionName("SetSmsOrderPay")]
        public Result_Model SetSmsOrderPay()
        {
            string msg = "";
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            Stream xmlStream = System.Web.HttpContext.Current.Request.InputStream;
            StreamReader rd = new StreamReader(xmlStream);
            string json = rd.ReadToEnd();
            Hashtable row = (Hashtable)PluSoft.Utils.JSON.Decode(json);
            string openid = CommonFun.ConvertToString(row["openid"]);
            decimal total_fee = CommonFun.ConvertToDecimal(row["total_fee"]);
            int total_qty = CommonFun.ConvertToInt(row["total_qty"]);

            int shop_id = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.CorpID);
            int user_id = SystemInfo.GetSystemAppID(shop_appid, SystemAppID.UserID);

            if ((shop_id < 20) || (shop_id == 44)) total_fee = CommonFun.ConvertToDecimal(0.01);

            int type = 2;//0是充值续费，2是短信充值
            //生成支付订单
            string out_trade_no = MiniMngCommon.SaveRenewalsOrder(shop_id, user_id, total_fee, total_qty, ref msg, type, shop_appid);
            if (out_trade_no == "") return new Result_Model(2, !string.IsNullOrEmpty(msg) ? msg : "生成订单失败");

            //开始调用支付
            Dictionary<string, object> result = new Dictionary<string, object>();
            bool ret = SxfPayCommon.GetCreateOrderPay(shop_id, openid, total_fee, out_trade_no, ref msg, out result);
            if (!ret) return new Result_Model(2, !string.IsNullOrEmpty(msg) ? msg : "获取失败");

            //查询支付结果
            MiniMngCommon.SetRepeatQueryPay(null, out_trade_no, shop_id, total_qty, type, shop_appid);
            return new Result_Model(1, "获取成功", result);
        }

        /// <summary>
        /// 1.69、短信签名保存
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("SetSmsSignInfo")]
        public Result_Model SetSmsSignInfo()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            string FSmsSign = CommonFun.ConvertToString(HttpContext.Current.Request["FSmsSign"]);
            int mResult = 0;
            string msg = "保存失败";

            Hashtable data = MiniMngCommon.SetSmsSignInfo(shop_appid, FSmsSign, ref mResult, ref msg);
            return new Result_Model(mResult, msg, data);
        }

        /// <summary>
        /// 1.70、导购明细
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptDawEmpDetail")]
        public Result_Model RptDawEmpDetail()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            int type = CommonFun.ConvertToInt(HttpContext.Current.Request["type"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            ArrayList data = MiniMngCommon.RptDawEmpDetail(shop_appid, shop_id, type, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }

        /// <summary>
        /// 1.71、收银明细
        /// </summary>
        [HttpPost, HttpGet]
        [ActionName("RptCashDetail")]
        public Result_Model RptCashDetail()
        {
            string shop_appid = CommonFun.ConvertToString(HttpContext.Current.Request.Headers["shop_appid"]);
            int page_index = CommonFun.ConvertToInt(HttpContext.Current.Request["page_index"]) - 1;
            int page_size = CommonFun.ConvertToInt(HttpContext.Current.Request["page_size"]);
            int shop_id = CommonFun.ConvertToInt(HttpContext.Current.Request["shop_id"]);
            string star_date = CommonFun.ConvertToString(HttpContext.Current.Request["star_date"]);
            string end_date = CommonFun.ConvertToString(HttpContext.Current.Request["end_date"]);
            string bill_no = CommonFun.ConvertToString(HttpContext.Current.Request["bill_no"]);
            ArrayList data = MiniMngCommon.RptCashDetail(shop_appid, shop_id, bill_no, page_index, page_size,
                star_date, end_date, out int page_count);
            return new Result_Model(1, "获取成功", data, data != null ? 1 : 0, page_count);
        }


    }
}